<template>
	<view class="staff-details">
		<!-- 头部 -->
		<!-- #ifndef MP-WEIXIN -->
		<public-header :title="title" :share="false"></public-header>
		<view class="hei_100"></view>
		 <!-- #endif -->
		<!-- end -->

		<!-- 内容 -->
		<public-order v-if="detail" :staff="staff" :detail="detail" :ticket="ticket"></public-order>

		<view class="nologin" v-else>
			<image src="/static/images/middle_image@2x.png" mode="widthFix"></image>
			<view>您还未登录，无法查看订单</view>
			<navigator url="/pages/register/login">去登陆</navigator>
		</view>
		<!-- end -->
	</view>
</template>

<script>
import { mapState, mapMutations } from 'vuex';
import PublicHeader from '@/components/PublicHeader.vue';
import PublicOrder from '@/components/PublicOrder.vue';
export default {
	computed: mapState(['hasLogin', 'uerInfo']),
	components: {
		PublicHeader,
		PublicOrder
	},
	data() {
		return {
			title: '订单详情',
			time: '12:01',
			staff: true,
			detail: '',
			ticket: '',
			share: '',
			id: ''
		};
	},
	onLoad(option) {
		var _this = this;
		let query  = JSON.parse(option.query)
		if (option && option.id) {
			query.id = option.id
		} else{
			query.id = ''
		}
		this.detail = query
		console.log('detail:',this.detail)
		// 优惠券
		if (_this.hasLogin) {
			_this.$http
				.get('/personal/center/getusercoupons/' + _this.uerInfo.userId)
				.then(function(response) {
					_this.ticket = response.data;
				})
				.catch(function(error) {
					console.log(error);
				});
		}

		// 分享金
		// if(_this.hasLogin){
		// 	_this.$http.get('/personal/center/getbrokerageandbalances/1').
		// 	then(function (response) {
		// 		_this.share = response.data.brokerage
		// 		console.log('个人信息987654321',response)
		// 	}).catch(function (error) {
		// 		console.log(error);
		// 	});
		// }
		// if(this.hasLogin){
		// 	_this.$http.get('/personal/center/getuser/'+this.uerInfo.userId).
		// 	then(function (response) {
		// 		console.log('个人信息',response)
		// 		if(response.msg == '登录异常'){
		// 			_this.bindLogin()
		// 		}
		// 	}).catch(function (error) {
		// 		console.log(error);
		// 	});
		// }
		
	},
	methods: {
		...mapMutations(['logout']),
		bindLogin() {
			if (this.hasLogin) {
				this.logout();
			} else {
				uni.navigateTo({
					url: '/pages/register/login'
				});
			}
		}
	}
};
</script>

<style scoped lang="scss">
/* 未登录状态 */
.nologin {
	width: 100%;
}
.nologin image {
	width: 500rpx;
	display: block;
	margin: 0 auto;
	margin-top: 178rpx;
}
.nologin view {
	font-size: 28rpx;
	color: #333;
	text-align: center;
	margin-top: 25rpx;
}
.nologin navigator {
	width: 412rpx;
	height: 90rpx;
	background-color: $uni-color1;
	line-height: 90rpx;
	color: #fff;
	font-size: 36rpx;
	text-align: center;
	border-radius: 45rpx;
	margin: 0 auto;
	margin-top: 100rpx;
}
</style>
